package zx.x.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zx.x.modules.app.entity.CateringEntity;
import zx.x.modules.app.service.CateringService;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.R;
import zx.x.modules.app.vo.CateringVo;


/**
 * 餐饮套餐
 *
 * @author x
 * @email x
 * @date 2022-12-07 18:08:42
 */
@RestController
@RequestMapping("/app/catering")
public class CateringController {
    @Autowired
    private CateringService cateringService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("app:catering:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cateringService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/queryById")
    public R info(CateringVo cateringVo){
		CateringVo catering = cateringService.queryById(cateringVo);

        return R.ok().put("catering", catering);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("app:catering:save")
    public R save(@RequestBody CateringEntity catering){
		cateringService.save(catering);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("app:catering:update")
    public R update(@RequestBody CateringEntity catering){
		cateringService.updateById(catering);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("app:catering:delete")
    public R delete(@RequestBody Integer[] ids){
		cateringService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
